#! /usr/bin/python
# -*- coding: cp1250 -*-
#import sys; sys.path.append(r'C:/xxx/yyy')

import glob, re, string, sys, os, time
import pepe.p_txt.bigtxt as bt

iso_time_now = lambda : time.strftime ("%Y-%m-%dT%H-%M-%S", time.localtime())
datenow = lambda : time.strftime ("%Y%m%d", time.localtime())
yyyymmddThhmmss = lambda : re.sub('[-:]','', iso_time_now())

def main(ifl, ofl):
    ''' standard template
    '''
    ## redirect stdo to file
    #sys.stdout = open(ofl, 'w')
    ## close and redirect stdo back to normal
    #sys.stdout=sys.__stdout__

    output = open(ofl, 'w')
    output.write('URLS'+datenow()[2:]+'\n')
    lino = 0
    for inpfile in glob.glob(ifl):
        for line in bt.lines(inpfile):
            line = re.sub('\n', '', line)
            m = re.search("^URL=", line)
            if m:
                output.write('# [[' + inpfile[:-4][:60] + ' ... |'+ line[4:] + ']]\n')
    output.close()

if __name__ == "__main__":
    main('*.url', '#urltw_' + yyyymmddThhmmss() + '.txt')
